home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1987 May & June / rerun-1987-05-06.d64 / puzzler's choice (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1987-01-01  |  13.1 KB  |  389 lines

  1. 10 rem - puzzler's choice for c=64
  2. 20 rem - daniel miller
  3. 30 rem - astoria, n.y.   11103
  4. 40 rem - 4/19/86
  5. 50 vo=54296:wv=54276:at=54277:hi=54273:lo=54272:mv=0:goto110
  6. 60 poke781,p/40:poke782,p-40*peek(781):poke783,0:sys65520:return
  7. 65 poke785,232:poke786,7:poke209,232:poke210,7:poke211,0:poke213,39
  8. 66 print" s&$[146][223]hd[146][193]$[146][160]d[146][194][160]":pokerl,peek(rl):rl=usr(rl):return
  9. 70 pokevo,15:pokewv,17:pokeat,15:pokehi,68:pokelo,149
  10. 80 fortm=1to100:next:pokewv,0
  11. 90 pokevo,15:pokewv,17:pokeat,15:pokehi,34:pokelo,75
  12. 100 fortm=1to100:next:pokewv,0:return
  13. 110 poke53280,2:poke53281,0:poke646,1
  14. 120 print"[147]":p=53:gosub60:print"puzzler's choice[146]":print
  15. 130 p=170:gosub60:print"select choice:":print
  16. 140 print"     1. alphabet puzzle":print"     2. juggernaut":
  17. 150 print"     3. checkers switch":print"     4. end program":print
  18. 160 printtab(15)" enter (1-4): ";:ct=fre(0)
  19. 170 getch$:ifch$<"1"orch$>"4"then170
  20. 180 printch$:on val(ch$)goto200,1420,2510,190
  21. 190 end
  22. 200 dima$(16),b$(16),lt$(16),lu$(16),a(16),d1$(4,4)
  23. 210 aa=0:l2=rnd(-ti):x1=16:goto1230
  24. 220 print"[147]":poke53281,11
  25. 230 p=54:gosub60:print"alphabet puzzle[146]":print:ct=fre(0)
  26. 240 rem - puzzle screen
  27. 250 p=120:gosub60:print"";
  28. 260 printtab(15)a$(1);"[145][145]"a$(2);"[145][145]"a$(3);"[145][145]"a$(4)
  29. 270 printtab(15)a$(5);"[145][145]"a$(6);"[145][145]"a$(7);"[145][145]"a$(8)
  30. 280 printtab(15)a$(9);"[145][145]"a$(10);"[145][145]"a$(11);"[145][145]"a$(12)
  31. 290 printtab(15)a$(13);"[145][145]"a$(14);"[145][145]"a$(15);"[145][145]"a$(16)
  32. 300 ifmv>0thengosub70
  33. 310 ifaa=0then330
  34. 320 onaa-1 goto610,750,820
  35. 330 p=686:gosub60:print" your goal in this puzzle is to"
  36. 340 print" rearrange the letters on the playing"
  37. 350 print" board into order to be displayed on"
  38. 360 print" the screen."
  39. 370 p=926:gosub60:print"[158]press <return> to continue[146]";
  40. 380 wait 198,1:get rt$
  41. 390 fory=17to24:poke781,y:sys59903:next
  42. 400 p=682:gosub60:print"  there are more than ten trillion"
  43. 410 print" letter combinations.":print
  44. 420 print"   press 'f7' to end the puzzle.":print
  45. 430 printtab(14)"happy puzzling !";
  46. 440 fortm=1to4000:nexttm
  47. 450 fory=17to24:poke781,y:sys59903:next
  48. 460 p=844:gosub60:print"[159]press <return> to scramble letters[146]";:poke198,0
  49. 470 wait 198,1:get rt$
  50. 480 rt$="":poke781,21:sys59903
  51. 490 rem - scramble letters on puzzle screen
  52. 500 forx=1to16:a(x)=0:nextx
  53. 510 forlt=1to16:lt$(lt)=mid$(d$,lt,1):nextlt
  54. 520 l1=1
  55. 530 forll=1to16
  56. 540 l2=int(16*rnd(1))+1
  57. 550 ifa(l2)>0then540
  58. 560 lu$(l1)=lt$(l2):a(l2)=l2:l1=l1+1:nextll
  59. 570 d$="":forx=1to16:d$=d$+lu$(x):nextx
  60. 580 forx=1to16:lt$(x)="":a(x)=0:nextx
  61. 590 aa=2:goto1240
  62. 600 rem - is arrangement possible ?
  63. 610 ct=0:z=1:fory=1to16
  64. 620 forx=zto15:ifmid$(d$,x+1,1)<lu$(z)thenct=ct+1
  65. 630 nextx:z=z+1:nexty
  66. 640 iflu$(2)="p"orlu$(4)="p"orlu$(5)="p"orlu$(7)="p"thenct=ct+1:goto660
  67. 650 iflu$(10)="p"orlu$(12)="p"orlu$(13)="p"orlu$(15)="p"thenct=ct+1
  68. 660 poke781,18:sys59903
  69. 670 rem - ct:even - yes; ct:odd - no
  70. 680 ifct/2=int(ct/2)then700
  71. 690 goto500
  72. 700 e$="":forx=1to16:e$=e$+lu$(x):nextx:rem - solution format
  73. 710 p=970:gosub60:print"[159]press <return> to begin[146]";
  74. 720 wait 198,1:get rt$
  75. 730 poke781,21:sys59903:poke781,24:sys59903:rt$=""
  76. 740 aa=3:goto1230
  77. 750 forx=1to16:iflu$(x)="p"thenlu$(x)="[158] [146][159]":goto770
  78. 760 nextx
  79. 770 p=270:gosub60:print"[159]solve[146]"
  80. 780 p=350:gosub60:printlu$(1);" ";lu$(2);" ";lu$(3);" ";lu$(4)
  81. 790 printtab(30);lu$(5);" ";lu$(6);" ";lu$(7);" ";lu$(8)
  82. 800 printtab(30);lu$(9);" ";lu$(10);" ";lu$(11);" ";lu$(12)
  83. 810 printtab(30);lu$(13);" ";lu$(14);" ";lu$(15);" ";lu$(16)
  84. 820 ifd$=e$then1100:rem - puzzle solved
  85. 830 forx=1to16:lt$(x)=mid$(d$,x,1):next x
  86. 840 x=1:forro=1to4:forcl=1to4:d1$(ro,cl)=mid$(d$,x,1):x=x+1:nextcl,ro
  87. 850 forro=1to4:forcl=1to4:ifd1$(ro,cl)="p" thenr1=ro:c1=cl
  88. 860 nextcl,ro:p=852:gosub60:print"press 'f7' to end"
  89. 870 p=696:gosub60:print"letter ?[159] [146]";:poke198,0
  90. 880 getlt$:iflt$=""then880
  91. 890 iflt$="[136]"then1210
  92. 900 iflt$<"a"orlt$>"o"thenlt$="":goto880
  93. 910 print"";lt$;
  94. 920 forro=1to4:forcl=1to4:ifd1$(ro,cl)=lt$then r2=ro:c2=cl
  95. 930 nextcl,ro
  96. 940 ifabs(r1-r2)=1 and abs(c1-c2)=1 then960
  97. 950 ifsqr((r1-r2)^2+(c1-c2)^2)=1 then990
  98. 960 forx=1to5:p=935:gosub60:print"invalid move[146]";:fortm=1to500:nexttm
  99. 970 poke781,23:sys59903:fortm=1to500:nexttm,x
  100. 980 p=705:gosub60:print" ";:goto870
  101. 990 forx=1to16:iflt$(x)=lt$thenx1=x
  102. 1000 nextx
  103. 1010 forx=1to16:iflt$(x)="p"thenx2=x
  104. 1020 nextx
  105. 1030 lt$(x1)="p":lt$(x2)=lt$
  106. 1040 d$="":forx=1to16:d$=d$+lt$(x):nextx
  107. 1050 p=705:gosub60:print"  ";
  108. 1060 p=776:gosub60:print"[158]move # [146]";
  109. 1070 mv=mv+1:p=782:gosub60:print"[158]";str$(mv)"[146]";
  110. 1080 aa=4:goto1240
  111. 1090 rem - end puzzle
  112. 1100 p=808:gosub60:print"you've solved the puzzle![146]";
  113. 1110 forcl=lo to lo+24:pokecl,0:next
  114. 1120 pokelo+5,85:pokelo+6,85:pokelo+12,85:pokelo+13,85:pokelo+24,15
  115. 1130 pokelo+4,33:pokelo+11,17:rl=1190:gosub65
  116. 1140 forx=1to6:readh1,l1,h2,l2:pokelo,l1:pokelo+1,h1:pokelo+7,l2:pokelo+8,h2
  117. 1150 ifh1=50thenfortm=1to200:nexttm
  118. 1160 fortm=1to100:nexttm
  119. 1170 nextx
  120. 1180 forcl=lo to lo+24:pokecl,0:next
  121. 1190 data25,30,18,209,33,135,25,30,42,62,31,165,50,60,37,162,42,62,31,165
  122. 1200 data50,60,37,162
  123. 1210 p=927:gosub60:print"[159]thanks for playing.  'bye'.[146]";
  124. 1220 fortm=1to1500:nexttm:poke198,0:run
  125. 1230 d$="abcdefghijklmnop":rem - puzzle format
  126. 1240 forx=1to16:ifmid$(d$,x,1)="p" thenx1=x
  127. 1250 nextx:ifmv=0then1280
  128. 1260 forx=1to16:ifmid$(d$,x,1)=lt$ then a=asc(lt$)-64:a$=lt$:goto1300
  129. 1270 nextx
  130. 1280 forx=1to16:a$(x)=""
  131. 1290 a$=mid$(d$,x,1)
  132. 1300 b=(a$="a")+(a$="c")+(a$="f")+(a$="h")+(a$="i")+(a$="k")+(a$="n")
  133. 1305 b=-1320*(b=-1)-1350*(b=0)
  134. 1310 poke785,188:poke786,168:pokeb,peek(b):b=usr(0)
  135. 1320 a$(x)="[166][166][166][157][157][157][166][146]"+a$+"[166][157][157][157][166][166][166][146]":rem "[166]" is 'c= +' [chr$(166)]
  136. 1330 ifmv>0then1380
  137. 1340 nextx:goto1380
  138. 1350 a$(x)="   [157][157][157] [146]"+a$+" [157][157][157]   [146]"
  139. 1360 ifmv>0then1380
  140. 1370 nextx
  141. 1380 a$(x1)="[158]   [157][157][157]   [157][157][157]   [146]"
  142. 1390 ifaa=0then220
  143. 1400 goto230
  144. 1410 rem - juggernaut main loop
  145. 1420 dim lc%(10),ch$(10),sp(2),sp$(10):goto2400
  146. 1430 p=788:gosub60:print" [157]";:ct=fre(0):poke198,0
  147. 1440 getmv$:forx=1to11:ifmv$=mid$("[133][136]abcdefghi",x,1)then1460
  148. 1450 next:goto1440
  149. 1460 ifmv$="[136]"then1800
  150. 1470 if mv$<>"[133]"then1500
  151. 1480 sol=1:s=0:mv=0:sol$="beha":goto2420
  152. 1490 s=s+1:mv$=mid$(sol$,s,1)
  153. 1500 p=788:gosub60:print mv$
  154. 1510 if ch$(asc(mv$)-64)<>"x" and ch$(asc(mv$)-63)<>"x" then1530
  155. 1520 msg$="invalid move[146]":p1=855:gosub1860:goto1430
  156. 1530 for x=1 to 10:if ch$(x)="x" thenlc=x:ld=x+1:goto1550
  157. 1540 next
  158. 1550 sp(1)=asc(mv$)-64:sp(2)=asc(mv$)-63
  159. 1560 rem - move checkers
  160. 1570 for y=ly% to lz% step-1
  161. 1580 pokev+val(sp$(sp(2))),y:pokev+val(sp$(sp(1))),y:next
  162. 1590 if sp(1)>lc then1640
  163. 1600 for x=lx%(sp(2)) to lx%(ld)
  164. 1610 pokev+val(sp$(sp(2)))-1,x:next
  165. 1620 for x=lx%(sp(1)) to lx%(lc)
  166. 1630 pokev+val(sp$(sp(1)))-1,x:next:goto1680
  167. 1640 for x=lx%(sp(1)) to lx%(lc) step-1
  168. 1650 pokev+val(sp$(sp(1)))-1,x:next
  169. 1660 for x=lx%(sp(2)) to lx%(ld) step-1
  170. 1670 pokev+val(sp$(sp(2)))-1,x:next
  171. 1680 for y=lz% to ly%
  172. 1690 pokev+val(sp$(sp(2))),y:pokev+val(sp$(sp(1))),y:next
  173. 1700 rem - update arrays & move-ctr
  174. 1710 ch$(lc)=ch$(sp(1)):ch$(ld)=ch$(sp(2)):ch$(sp(1))="x":ch$(sp(2))="x"
  175. 1720 sp$(lc)=sp$(sp(1)):sp$(ld)=sp$(sp(2)):sp$(sp(1))="xx":sp$(sp(2))="xx"
  176. 1730 mv=mv+1:p=516:gosub60:print""right$(str$(mv),len(str$(mv))-1)"[146]";
  177. 1740 slv$="":for x=1 to 10:slv$=slv$+ch$(x):next
  178. 1750 if slv$=win$ then1780
  179. 1760 if sol=1 then1490
  180. 1770 goto1430
  181. 1780 if sol=1 then1800
  182. 1790 msg$="congratulations !![146]":p1=850:gosub1860
  183. 1800 poke781,21:sys59903:poke198,0:p=851:gosub60:print"try again [y/n]: ";
  184. 1810 get yn$:if yn$<>"y" and yn$<>"n" thenyn$="":goto1810
  185. 1820 print yn$:pokev+21,0
  186. 1830 if yn$="y" then run1420
  187. 1840 run
  188. 1850 rem - message rtn.
  189. 1860 p=p1+80:for x=1 to 5:gosub60:print msg$;:for tm=1 to 500:next tm
  190. 1870 poke781,23:sys59903:fortm=1to500:nexttm,x
  191. 1880 print"":return
  192. 1890 rem - set up screen
  193. 1900 p=95:gosub60:print"juggernaut[146]";
  194. 1910 p=402:gosub60:printl1$:p=p+40:gosub60:printl1$
  195. 1920 for x=1 to 3:gosub1930:next:goto1940
  196. 1930 printspc(2)l3$;spc(28)l3$:return
  197. 1940 p=p+160:gosub60:printl1$
  198. 1950 p=524:gosub60:for x=1 to 9:printl2$;:p=p+3:gosub60:next
  199. 1960 p=684:gosub60:for x=1 to 9:print""chr$(x+64);:p=p+3:gosub60:next
  200. 1970 p=434:gosub60:print"[150]move#[146]";
  201. 1980 rem - checker sprites
  202. 1990 v=53248:v1=2040:t=13:pokev+23,0:pokev+29,0
  203. 2000 pokev1,t:pokev1+1,t:pokev1+2,t:pokev1+3,t:pokev1+4,t
  204. 2010 pokev1+5,t:pokev1+6,t:pokev1+7,t
  205. 2020 rem - set up sprites
  206. 2030 rl=2170:gosub65
  207. 2040 for sp=832 to 894:read q1:pokesp,q1:next
  208. 2050 for x=39 to 45 step2:pokev+x,7:next
  209. 2060 for x=40 to 46 step2:pokev+x,2:next
  210. 2070 for y=1 to 15 step2:pokev+y,160:next
  211. 2080 z=40:for x=0 to 14 step2:pokev+x,z:z=z+24:next:pokev+21,255
  212. 2090 if zz=0 goto2150
  213. 2100 p=202:gosub60:print"solution:      [209] [209] [209] [209] [158][209] [209] [209] [209]";
  214. 2110 p=254:gosub60:print"a b c d e f g h i";
  215. 2120 if sol=1 then1490
  216. 2130 p=842:gosub60:print"'f1' - auto solve     'f7' - menu";
  217. 2140 p=770:gosub60:print"enter move [a-i]:";:goto1430
  218. 2150 l1$="":l2$="":l3$="":goto2240
  219. 2160 rem - sprite data
  220. 2170 data 0,0,0,0,0,0,0,0,0
  221. 2180 data 0,62,0,1,255,192,7,255,240
  222. 2190 data 15,255,248,31,255,252,63,255,254
  223. 2200 data 63,255,254,127,255,255,127,227,255
  224. 2210 data 127,227,255,63,255,254,63,255,254
  225. 2220 data 31,255,252,15,255,248,7,255,240
  226. 2230 data 1,255,192,0,62,0,0,0,0
  227. 2240 p=240:gosub60:print" your goal is to move the checkers from"
  228. 2250 print" these positions:";:for tm=1 to 3000:next:pokev+21,0
  229. 2260 gosub2380
  230. 2270 p=280:gosub60:print" to these positions:";
  231. 2280 for x=39 to 42:pokev+x,2:next
  232. 2290 for x=43 to 46:pokev+x,7:next
  233. 2300 for y=1 to 15 step2:pokev+y,160:next
  234. 2310 z=88:for x=0 to 12 step2:pokev+x,z:z=z+24:next:pokev+14,255:pokev+21,255
  235. 2320 for tm=1 to 2500:next:gosub2380
  236. 2330 p=240:gosub60:print" after you select a letter, the two"
  237. 2340 print" adjacent checkers above it will move.":for tm=1 to 3000:next:gosub2380
  238. 2350 p=240:gosub60:print" this puzzle can be solved in 4 moves."
  239. 2360 for tm=1 to 2500:next
  240. 2370 pokev+21,255:zz=1:gosub2380:goto2050
  241. 2380 poke781,6:sys59903:poke781,7:sys59903:return
  242. 2390 rem - initialization
  243. 2400 print"[147]":poke53280,11:poke53281,0
  244. 2410 win$="xxrrrryyyy":sol=0:s=0
  245. 2420 for x=2 to 8 step2:ch$(x)="r":next:for x=1 to 7 step2:ch$(x)="y":next
  246. 2430 ch$(9)="x":ch$(10)="x"
  247. 2440 lz%=140:ly%=160:lw%=40:for x=1 to 9:lx%(x)=lw%:lw%=lw%+24:next
  248. 2450 lx%(10)=255
  249. 2460 sp%=1:for x=1 to 8:sp$(x)=str$(sp%):sp%=sp%+2:next
  250. 2470 if sol=1 then2370
  251. 2480 l1$="[159]                              [146]":l2$="[159]  [157][157]  [146]":l3$="[159] [146]"
  252. 2490 goto1900
  253. 2500 rem - switch
  254. 2510 dim b(45),c(45),a$(4),er$(5):gosub3610:goto3270
  255. 2520 rem- puzzle screen
  256. 2530 ct=fre(0):p=13:gosub60:printhdg$;
  257. 2540 p=129:gosub60:print"1[146]  2[146]  3[146]  4[146]  5[146]  6[146]  7[146]  8[146]  9[146]"
  258. 2550 p=160:gosub60:print"";
  259. 2560 printtab(8)a$(b(1))"[145][145]"a$(b(2))"[145][145]"a$(b(3))"[145][145]"a$(b(4))"[145][145]"a$(b(5))"[145][145]";
  260. 2570 printtab(21)a$(b(6))"[145][145]"a$(b(7))"[145][145]"a$(b(8))"[145][145]"a$(b(9))
  261. 2580 if val(f2$)<>1 then2600
  262. 2590 gosub70
  263. 2600 printtab(8)a$(b(10))"[145][145]"a$(b(11))"[145][145]"a$(b(12))"[145][145]"a$(b(13))"[145][145]"a$(b(14));
  264. 2610 printtab(21)"[145][145]"a$(b(15))"[145][145]"a$(b(16))"[145][145]"a$(b(17))"[145][145]"a$(b(18))
  265. 2620 if val(f2$)<>2 then2640
  266. 2630 gosub70
  267. 2640 printtab(8)a$(b(19))"[145][145]"a$(b(20))"[145][145]"a$(b(21))"[145][145]"a$(b(22))"[145][145]"a$(b(23));
  268. 2650 printtab(21)"[145][145]"a$(b(24))"[145][145]"a$(b(25))"[145][145]"a$(b(26))"[145][145]"a$(b(27))
  269. 2660 if val(f2$)<>3 then2680
  270. 2670 gosub70
  271. 2680 printtab(8)a$(b(28))"[145][145]"a$(b(29))"[145][145]"a$(b(30))"[145][145]"a$(b(31))"[145][145]"a$(b(32));
  272. 2690 printtab(21)"[145][145]"a$(b(33))"[145][145]"a$(b(34))"[145][145]"a$(b(35))"[145][145]"a$(b(36))
  273. 2700 if val(f2$)<>4 then2720
  274. 2710 gosub70
  275. 2720 printtab(8)a$(b(37))"[145][145]"a$(b(38))"[145][145]"a$(b(39))"[145][145]"a$(b(40))"[145][145]"a$(b(41));
  276. 2730 printtab(21)"[145][145]"a$(b(42))"[145][145]"a$(b(43))"[145][145]"a$(b(44))"[145][145]"a$(b(45))
  277. 2740 if val(f2$)<>5 then2760
  278. 2750 gosub70
  279. 2760 ifmv=0then x=49:forp=206to686step120:gosub60:print""chr$(x);:x=x+1:nextp
  280. 2770 p=765:gosub60:print"'f1' - auto solve   'f7' - menu";
  281. 2780 p=857:gosub60:print"[156]move #[146]";
  282. 2790 p=931:gosub60:print"[159]from ?"spc(9)"to ?[146]"
  283. 2800 if d$=e$ then3170:rem - puzzle solved
  284. 2810 if zz=1 then for tm=1 to 2000:next tm:return
  285. 2820 rem- move routine
  286. 2830 p=939:gosub60:print"    ";spc(11)"    ";
  287. 2840 p=939:gosub60:print"   ";:gosub60:printcr$;:ifsol=0 then2860
  288. 2850 p=939:gosub60:read fr$,tu$
  289. 2855 print""left$(fr$,1);"";right$(fr$,1);"[146]";
  290. 2856 printspc(9)"  ";left$(tu$,1);"";right$(tu$,1);"[146]";:goto2960
  291. 2860 getf$:forx=1to7:iff$=mid$("[133][136]12345",x,1)then2880
  292. 2870 nextx:f$="":goto2860
  293. 2880 if f$<>"[133]"then2910
  294. 2890 sol=1:s=0:mv=0:zz=0
  295. 2900 d$="":e$="":f2$="":mo$="":ct=fre(0):gosub3750:goto2530
  296. 2910 if f$="[136]"then3590
  297. 2920 print""f$;:poke198,0
  298. 2930 getg$:forx=1to9:ifg$=mid$("123456789",x,1)then2950
  299. 2940 nextx:goto2930
  300. 2950 print""g$"[146]";:fr$=f$+g$:f$="":g$=""
  301. 2960 h=val(fr$):gosub3500:fr=h:c(fr)=val(mid$(d$,fr,1)):ifsol=1then3030
  302. 2970 p=950:gosub60:print"    ";:p=951:gosub60:printcr$;:poke198,0
  303. 2980 getf$:forx=1to5:ifmid$("12345",x,1)=f$thenprint""f$;:poke198,0:goto3000
  304. 2990 nextx:goto2980
  305. 3000 getg$:forx=1to9:ifmid$("123456789",x,1)=g$thenprint""g$"[146]";:goto3020
  306. 3010 nextx:goto3000
  307. 3020 tu$=f$+g$:f$="":g$=""
  308. 3030 h=val(tu$):gosub3500:tu=h:c(tu)=val(mid$(d$,tu,1))
  309. 3040 z1=val(left$(fr$,1)):z2=val(right$(fr$,1))
  310. 3050 z3=val(left$(tu$,1)):z4=val(right$(tu$,1))
  311. 3060 f2$=left$(fr$,1)
  312. 3070 fr$=mid$(d$,fr,1):tu$=mid$(d$,tu,1)
  313. 3080 if fr$="4" then er=1:goto3230
  314. 3090 if tu$="1" or tu$="2" then er=2:goto3230
  315. 3100 if fr$="3" or tu$="3" then er=3:goto3230
  316. 3110 if z1=z3 or z2=z4 then er=4:goto3230
  317. 3120 c=c(tu):c(tu)=c(fr):c(fr)=c
  318. 3130 d$="":for x=1 to 45:d$=d$+right$(str$(c(x)),1):next x
  319. 3140 p=979:gosub60:print"    ";spc(11)"    ";
  320. 3150 for x=1 to 45:b(x)=val(mid$(d$,x,1)):next x
  321. 3160 mv=mv+1:mo$=""+str$(mv)+"[146]":p=864:gosub60:printmo$;:goto2530
  322. 3170 ifsol=1then3590
  323. 3180 for x=1 to 5
  324. 3190 p=967:gosub60:print"you solved the puzzle![146]":fortm=1to1500:next
  325. 3200 poke781,24:sys59903:fortm=1to500:nexttm,x
  326. 3210 goto3590
  327. 3220 rem- flash error messages
  328. 3230 f2$="":tb=(24-(len(er$(er))/2)):poke781,24:sys59903:forx=1to5
  329. 3240 p=960:gosub60:printtab(tb)er$(er);:fortm=1to500:nexttm
  330. 3250 poke781,24:sys59903:fortm=1to500:nexttm,x:goto2530
  331. 3260 rem- instructions
  332. 3270 poke 53281,1
  333. 3280 print"[147]"chr$(14):p=132:gosub60:printh2$;:print:print
  334. 3290 print"      [208]repare to test your puzzler's":print
  335. 3300 print"  skills.  [197]ight [215]hite[146] checkers and":print
  336. 3310 print"  eight [144][194]lack[146] checkers are positioned":print
  337. 3320 print"  on opposite sides of the checkerboard ";:print
  338. 3330 print"  as shown:"
  339. 3340 zz=1:gosub3480:poke53281,1
  340. 3350 print"[147]":p=132:gosub60:printh2$;:print:print:zz=0
  341. 3360 print"    [217]our goal is to switch the checkers":print
  342. 3370 print"  to the reverse sides of the board.  [193]":print
  343. 3380 print"  checker can be moved to a [210]ed[146] square":print
  344. 3390 print"  or can be jumped over another piece":print
  345. 3400 print"  to another [210]ed[146] square.  [215]hite[146] pieces":print
  346. 3410 print"  move to the [210][201][199][200][212]; [144][194]lack[146] checkers":print
  347. 3420 print"  can move only to the [204][197][198][212]."
  348. 3430 for tm=1 to 3000:next tm
  349. 3440 print"[147]":p=120:gosub60:printchr$(14)"[195]heckers [211]witch";:print:print
  350. 3450 print"     [212]his puzzle can be solved in 52":print
  351. 3460 print"  moves.":print:print
  352. 3470 print"     [200]ave fun and [199]ood [204]uck !"
  353. 3480 for tm=1 to 2500:next tm:print"[147]":d$="":e$="":f2$="":gosub3750
  354. 3490 mv=0:poke53281,11:print"[147]"chr$(142):goto2530
  355. 3500 rem- convert 'from-to' position in string
  356. 3510 ifh>10thenifh<20thenifh/2<>int(h/2)thenh=h-10:return
  357. 3520 ifh>21thenifh<29thenifh/2=int(h/2)thenh=h-11:return
  358. 3530 ifh>30thenifh<40thenifh/2<>int(h/2)thenh=h-12:return
  359. 3540 ifh>41thenifh<49thenifh/2=int(h/2)thenh=h-13:return
  360. 3550 ifh>50thenifh<60thenifh/2<>int(h/2)thenh=h-14:return
  361. 3560 er=3:goto3230:rem - move invalid
  362. 3570 rem- end puzzle message
  363. 3580 poke781,23:sys59903
  364. 3590 p=928:gosub60:print"thanks for playing.  'bye.[146]";
  365. 3600 fortm=1to3000:next:run
  366. 3610 rem- build character graphics
  367. 3620 gr$="   [146][157][157][157]"
  368. 3630 a$(1)=gr$+" [146][209] [146][157][157][157]   [146]"
  369. 3640 a$(2)=gr$+" [146][144][209] [146][157][157][157]   [146]"
  370. 3650 a$(3)="   [146][157][157][157]   [146][157][157][157]   [146]"
  371. 3660 a$(4)=gr$+"   [146][157][157][157]   [146]"
  372. 3670 gr$="":cr$="[158] [146]"
  373. 3680 hdg$="[158]checkers switch[146]":h2$=chr$(14)+"[195]heckers [211]witch[146]"
  374. 3690 rem- errors
  375. 3700 er$(1)="[158]'from' position empty[146]":er$(2)="[158]'to' position occupied[146]"
  376. 3710 er$(3)="[158]invalid 'from-to' position[146]"
  377. 3720 er$(4)="[158]move not diagonal[146]":er$(5)="[158]invalid move[146]"
  378. 3730 f2=0:f2$="":rl=3790:gosub65
  379. 3740 rem- puzzle format
  380. 3750 d$="431343234313132323131343232313132323431343234"
  381. 3760 printchr$(142):forx=1to45:b(x)=val(mid$(d$,x,1)):c(x)=b(x):nextx
  382. 3770 rem- puzzle solved format
  383. 3780 e$="432343134323231313232343131323231313432343134":return
  384. 3790 data26,35,44,26,35,44,24,35,46,24,37,46,26,37,17,26,35,17,13,35,24,13
  385. 3800 data33,24,44,33,26,44,35,26,46,35,24,46,42,24,31,42,13,31,22,13,33,22
  386. 3810 data44,33,53,44,35,53,57,35,48,57,39,48,17,39,28,17,37,28,48,37,26,48
  387. 3820 data44,26,35,44,17,35,26,17,37,26,46,37,24,46,35,24,13,35,24,13,42,24
  388. 3830 data33,42,44,33,26,44,35,26,57,35,46,57,24,46,35,24
  389.